<?php
include dirname(__FILE__)."/../database/database.class.php";

$foil = FALSE;
if(isset($_GET['foil']) && $_GET['foil'] == 1)
{
  $foil = TRUE;
}

if(isset($_GET['action']))
{
  if(isset($_GET['cardid'], $_GET['collectionid']))
  {
    if($_GET['action'] == "ADD")
    {
      $db->addToCollection($_GET['cardid'], $_GET['collectionid'], $foil);
    }
    else if($_GET['action'] == "DEL")
    {
      $db->delFromCollection($_GET['cardid'], $_GET['collectionid'], $foil);
    }
    $amount = $db->getAmountInCollection($_GET['cardid'], $_GET['collectionid']);
    echo $amount['normal']." | ".$amount['foil'];
  }
  if(isset($_GET['cardid'], $_GET['deckid']))
  {
    $db = new Database();
    if($_GET['action'] == "ADD")
    {
      $db->addToDeck($_GET['cardid'], $_GET['deckid'], $foil);
    }
    else if($_GET['action'] == "DEL")
    {
      $db->delFromDeck($_GET['cardid'], $_GET['deckid'], $foil);
    }
    $amount = $db->getAmountInDeck($_GET['cardid'], $_GET['deckid']);
    echo $amount['normal']." | ".$amount['foil'];
  }
}

?>
